﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;

namespace Transport
{
    public partial class Carprice : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected string GetAllService(string selected)
        {
            string html = null;
            DichVuControl dv = new DichVuControl();
            List<dich_vu> list = dv.listAll();
            foreach(dich_vu dichVu in list)
            {
                if(dichVu.id_dich_vu == selected)
                    html += "<option value=\""+dichVu.id_dich_vu+"\" selected>"+dichVu.ten_dich_vu+"</option>";
                else
                    html += "<option value=\"" + dichVu.id_dich_vu + "\">" + dichVu.ten_dich_vu + "</option>";
            }
            return html;
        }
        protected string GetAllMien(string selected)
        {
            string html = null;
            MienControl mien = new MienControl();
            List<mien> list = mien.listAll();
            foreach (mien item in list)
            {
                if (item.ma_mien == selected)
                    html += "<option value=\"" + item.ma_mien + "\" selected>" + item.ten_mien + "</option>";
                else
                    html += "<option value=\"" + item.ma_mien + "\">" + item.ten_mien + "</option>";
            }
            return html;
        }
        protected string getBangGiaTheoNgayByServiceID(string serviceID)
        {
            string html = "<thead>"
            +"<tr>"
                +"<th>Hiệu Xe</th>"
                +"<th>Giá Tiền</th>"
                +"<th>Giá Trang Trí</th>"
                +"<th>Giá ngoài giờ</th>"
                +"<th>Miền</th>"
                +"<th>Phí lưu đêm</th>"
                +"<th>Loại Xe</th>"
            +"</tr>"
        +"</thead>";
            BangGiaTrongNgayControl bangGia = new BangGiaTrongNgayControl();

            List<BangGiaTrongNgay> list = bangGia.GetBangGiaTrongNgay(serviceID);
            foreach (BangGiaTrongNgay item in list)
            {
                html += "<tbody><tr>"
                            +"<td>"+item.HieuXe+"</td>"
                            + "<td>" + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.GiaTien) + "</td>"
                            +"<td>"+String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.GiaTrangTri)+"</td>"
                            + "<td>" + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.GiaNgoaiGio) + "</td>"
                            +"<td>"+item.Mien+"</td>"
                            + "<td>" + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.PhiLuuDem) + "</td>"
                            +"<td>"+item.LoaiXe+" chỗ</td>"
                        +"</tr></tbody>";
            }

            return html;
        }
        protected string getBangGiaTheoNgayByServiceID()
        {
            string html = "<thead>"
            + "<tr>"
                + "<th>Hiệu Xe</th>"
                + "<th>Giá Tiền</th>"
                + "<th>Giá Trang Trí</th>"
                + "<th>Giá ngoài giờ</th>"
                + "<th>Miền</th>"
                + "<th>Phí lưu đêm</th>"
                + "<th>Loại Xe</th>"
            + "</tr>"
        + "</thead>";
            BangGiaTrongNgayControl bangGia = new BangGiaTrongNgayControl();

            List<BangGiaTrongNgay> list = bangGia.GetBangGiaTrongNgay();
            foreach (BangGiaTrongNgay item in list)
            {
                html += "<tbody><tr>"
                            + "<td>" + item.HieuXe + "</td>"
                            + "<td>" + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.GiaTien) + "</td>"
                            + "<td>" + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.GiaTrangTri) + "</td>"
                            + "<td>" + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.GiaNgoaiGio) + "</td>"
                            + "<td>" + item.Mien + "</td>"
                            + "<td>" + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.PhiLuuDem) + "</td>"
                            + "<td>" + item.LoaiXe + " chỗ</td>"
                        + "</tr></tbody>";
            }

            return html;
        }
        protected string getBangGiaTheoMienByServiceID(string mienID)
        {
            string html = "<thead>"
            + "<tr>"
                + "<th>Hiệu xe</th>"
                + "<th>Số chỗ</th>"
                + "<th>Lộ trình</th>"
                + "<th>Giá tiền</th>"
                + "<th>Chi phí vượt km</th>"
            + "</tr>"
        + "</thead>";
            XeControl xe = new XeControl();

            List<BGTLTentity> list = xe.listAllByRouteID(mienID);
            foreach (BGTLTentity item in list)
            {
                html += "<tbody><tr>"
                            + "<td>" + item.Ten_thuong_hieu + "</td>"
                            + "<td>" + item.So_cho + " chỗ</td>"
                            + "<td>" + item.Ten_lo_trinh + "</td>"
                            + "<td>" + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.Gia_tien) + " đ</td>"
                            + "<td>" + item.Chi_phi_vuot_km + " km</td>"
                        + "</tr></tbody>";
            }

            return html;
        }

        protected string getBangGiaTheoMienByServiceID()
        {
            string html = "<thead>"
            + "<tr>"
                + "<th>Hiệu xe</th>"
                + "<th>Số chỗ</th>"
                + "<th>Lộ trình</th>"
                + "<th>Giá tiền</th>"
                + "<th>Chi phí vượt km</th>"
            + "</tr>"
            + "</thead>";
            XeControl xe = new XeControl();

            List<BGTLTentity> list = xe.listAllByRoute();
            foreach (BGTLTentity item in list)
            {
                html += "<tbody><tr>"
                            + "<td>" + item.Ten_thuong_hieu + "</td>"
                            + "<td>" + item.So_cho + " chỗ</td>"
                            + "<td>" + item.Ten_lo_trinh + "</td>"
                            + "<td>" + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.Gia_tien) + " đ</td>"
                            + "<td>" + item.Chi_phi_vuot_km + " km</td>"
                        + "</tr></tbody>";
            }


            return html;
        }


    }
}